import {defineStore} from 'pinia'
import {ref} from 'vue'

export const useServerStore = defineStore('server', () => {
    const serverConfig = ref({
        host: '',
        port: 22,
        username: '',
        password: '',
        currentPath: '/'
    })

    const isConnected = ref(false)

    function setServerConfig(config: {
        host: string
        port: number
        username: string
        password: string
    }) {
        serverConfig.value = {...serverConfig.value, ...config}
    }

    function setCurrentPath(path: string) {
        serverConfig.value.currentPath = path
    }

    function setConnected(status: boolean) {
        isConnected.value = status
    }

    return {serverConfig, isConnected, setServerConfig, setCurrentPath, setConnected}
})